home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Workbench Add-On
/
Workbench Add-On - Volume 1.iso
/
Dev
/
Oberon
/
source
/
EAGUI
/
EASupport.mod
< prev
next >
Wrap
Text File
|
1995-06-29
|
9KB
|
334 lines
(*************************************************************************
$RCSfile: EASupport.mod $
Description: Support for clients of EAGUI.library
Created by: fjc (Frank Copeland)
$Revision: 1.2 $
$Author: fjc $
$Date: 1995/06/04 23:20:03 $
Copyright © 1995, Frank Copeland.
This file is part of Oberon-A.
See Oberon-A.doc for conditions of use and distribution.
*************************************************************************)
<* STANDARD- *>
<*$ StackChk- *>
<*$ LongVars+ *>
MODULE EASupport;
IMPORT
SYS := SYSTEM, e := Exec, u := Utility, gfx := Graphics, i := Intuition,
gt := GadTools, ea := EAGUI;
(*------------------------------------*)
VAR
SameSizeHook*,
SameHeightHook*,
SameWidthHook*
: u.HookPtr;
hook1, hook2, hook3 : u.Hook;
(*------------------------------------*)
(* same size relation *)
PROCEDURE SameSize*
( hook : u.HookPtr;
list : e.ListPtr;
msg : e.APTR )
: e.ULONG;
VAR
ro : ea.RelationObjectPtr;
minx, miny, x, y, ignore : e.ULONG;
BEGIN (* SameSize *)
minx := 0;
miny := 0;
(* examine the list of objects that are affected by the relation *)
ro := SYS.VAL (ea.RelationObjectPtr, list.head);
WHILE ro.node.succ # NIL DO
ignore := ea.GetAttrs ( ro.object_ptr,
ea.MinWidth, SYS.ADR (x),
ea.MinHeight, SYS.ADR (y),
u.done );
(* find the maximum values of the minimum sizes *)
IF x > minx THEN minx := x END;
IF y > miny THEN miny := y END;
ro := SYS.VAL (ea.RelationObjectPtr, ro.node.succ)
END;
(* set all objects to the newly found minimum sizes *)
ro := SYS.VAL (ea.RelationObjectPtr, list.head);
WHILE ro.node.succ # NIL DO
ignore := ea.SetAttrs ( ro.object_ptr,
ea.MinWidth, minx,
ea.MinHeight, miny,
u.done );
ro := SYS.VAL (ea.RelationObjectPtr, ro.node.succ)
END;
RETURN 0
END SameSize;
(*------------------------------------*)
(* same width relation *)
PROCEDURE SameWidth*
( hook : u.HookPtr;
list : e.ListPtr;
msg : e.APTR )
: e.ULONG;
VAR
ro : ea.RelationObjectPtr;
minx, x, ignore : e.ULONG;
BEGIN (* SameWidth *)
minx := 0;
(* examine the list of objects that are affected by the relation *)
ro := SYS.VAL (ea.RelationObjectPtr, list.head);
WHILE ro.node.succ # NIL DO
ignore := ea.GetAttrs ( ro.object_ptr,
ea.MinWidth, SYS.ADR (x),
u.done );
(* find the maximum values of the minimum sizes *)
IF x > minx THEN minx := x END;
ro := SYS.VAL (ea.RelationObjectPtr, ro.node.succ)
END;
(* set all objects to the newly found minimum sizes *)
ro := SYS.VAL (ea.RelationObjectPtr, list.head);
WHILE ro.node.succ # NIL DO
ignore := ea.SetAttrs ( ro.object_ptr,
ea.MinWidth, minx,
u.done );
ro := SYS.VAL (ea.RelationObjectPtr, ro.node.succ)
END;
RETURN 0
END SameWidth;
(*------------------------------------*)
(* same height relation *)
PROCEDURE SameHeight*
( hook : u.HookPtr;
list : e.ListPtr;
msg : e.APTR )
: e.ULONG;
VAR
ro : ea.RelationObjectPtr;
miny, y, ignore : e.ULONG;
BEGIN (* SameHeight *)
miny := 0;
(* examine the list of objects that are affected by the relation *)
ro := SYS.VAL (ea.RelationObjectPtr, list.head);
WHILE ro.node.succ # NIL DO
ignore := ea.GetAttrs ( ro.object_ptr,
ea.MinHeight, SYS.ADR (y),
u.done );
(* find the maximum values of the minimum sizes *)
IF y > miny THEN miny := y END;
ro := SYS.VAL (ea.RelationObjectPtr, ro.node.succ)
END;
(* set all objects to the newly found minimum sizes *)
ro := SYS.VAL (ea.RelationObjectPtr, list.head);
WHILE ro.node.succ # NIL DO
ignore := ea.SetAttrs ( ro.object_ptr,
ea.MinHeight, miny,
u.done );
ro := SYS.VAL (ea.RelationObjectPtr, ro.node.succ)
END;
RETURN 0
END SameHeight;
(*------------------------------------*)
PROCEDURE HandleSizeVerify*
( win : i.WindowPtr;
winObj : ea.OPTR;
VAR gadList : i.GadgetPtr );
VAR ignore : LONGINT;
BEGIN (* HandleSizeVerify *)
IF gadList # NIL THEN
ignore := i.RemoveGList ( win, gadList, -1 );
ea.FreeGadgetList ( winObj, gadList );
gadList := NIL
END
END HandleSizeVerify;
(*------------------------------------*)
PROCEDURE DoRender*
( win : i.WindowPtr;
winObj : ea.OPTR;
VAR gadList : i.GadgetPtr;
drawInfo : i.DrawInfoPtr;
visualInfo : gt.VisualInfo );
VAR
bl, br, bt, bb, ignore : LONGINT;
BEGIN (* DoRender *)
ignore := ea.GetAttrs ( winObj,
ea.BorderLeft, SYS.ADR (bl),
ea.BorderRight, SYS.ADR (br),
ea.BorderTop, SYS.ADR (bt),
ea.BorderBottom, SYS.ADR (bb),
u.done );
ignore := ea.SetAttrs ( winObj,
ea.Width, win.width -
win.borderLeft -
win.borderRight -
bl - br,
ea.Height, win.height -
win.borderTop -
win.borderBottom -
bt - bb,
ea.Left, win.borderLeft,
ea.Top, win.borderTop,
u.done );
ea.LayoutObjects ( winObj );
IF ea.CreateGadgetList ( winObj, gadList, visualInfo, drawInfo )
# ea.ERROR_OK
THEN
HALT (98)
END;
gfx.EraseRect ( win.rPort,
win.borderLeft,
win.borderTop,
win.width - win.borderRight - 1,
win.height - win.borderBottom - 1 );
i.RefreshWindowFrame ( win );
ignore := i.AddGList ( win, gadList, -1, -1, NIL );
i.RefreshGList ( gadList, win, NIL, -1 );
gt.RefreshWindow ( win, NIL );
(* finally, we render the imagery, if there is any *)
ea.RenderObjects ( winObj, win.rPort );
END DoRender;
(*------------------------------------*)
PROCEDURE OpenWindow*
( scrType : u.TagID;
scr : i.ScreenPtr;
winTitle : e.LSTRPTR;
winObj : ea.OPTR;
VAR win : i.WindowPtr );
VAR
w, h, bl, br, bt, bb, ignore : LONGINT;
wPtr, hPtr, blPtr, brPtr, btPtr, bbPtr : SYS.ADDRESS;
BEGIN (* OpenWindow *)
(* obtain the minimum dimensions of every object in the tree *)
ea.GetMinSizes ( winObj );
(* get some attributes *)
wPtr := SYS.ADR (w); hPtr := SYS.ADR (h);
blPtr := SYS.ADR (bl); brPtr := SYS.ADR (br);
btPtr := SYS.ADR (bt); bbPtr := SYS.ADR (bb);
ignore := ea.GetAttrs ( winObj,
ea.MinWidth, wPtr,
ea.MinHeight, hPtr,
ea.BorderLeft, blPtr,
ea.BorderRight, brPtr,
ea.BorderTop, btPtr,
ea.BorderBottom, bbPtr,
u.done );
(* open the window *)
win := i.OpenWindowTagsA ( NIL,
i.waTitle, winTitle,
i.waFlags, { i.windowDrag, i.windowDepth, i.windowClose,
i.windowSizing, i.sizeBBottom, i.activate },
i.waIDCMP, { i.closeWindow, i.refreshWindow, i.newSize }
+ gt.buttonIDCMP + gt.stringIDCMP,
i.waInnerHeight, h + bt + bb,
i.waInnerWidth, (w + bl + br) * 2,
scrType, scr,
u.done );
ASSERT (win # NIL, 98);
(* set the window limits *)
IF i.WindowLimits ( win,
w + win.borderLeft + win.borderRight + bl + br,
h + win.borderTop + win.borderBottom + bt + bb,
-1, -1 )
THEN END;
END OpenWindow;
(*------------------------------------*)
PROCEDURE CloseWindow*
( VAR win : i.WindowPtr;
VAR winObj : ea.OPTR;
VAR gadList : i.GadgetPtr );
VAR ignore : LONGINT;
BEGIN (* CloseWindow *)
IF gadList # NIL THEN
ignore := i.RemoveGList ( win, gadList, -1 );
ea.FreeGadgetList ( winObj, gadList );
gadList := NIL
END;
IF win # NIL THEN
i.CloseWindow ( win );
win := NIL
END;
IF winObj # NIL THEN
ea.DisposeObject ( winObj );
winObj := NIL
END
END CloseWindow;
(*------------------------------------*)
PROCEDURE Init ();
BEGIN (* Init *)
(* initialize the relations *)
SameSizeHook := SYS.ADR (hook1);
u.InitHook (SameSizeHook, SYS.VAL (u.HookFunc, SameSize));
SameWidthHook := SYS.ADR (hook2);
u.InitHook (SameWidthHook, SYS.VAL (u.HookFunc, SameWidth));
SameHeightHook := SYS.ADR (hook3);
u.InitHook (SameHeightHook, SYS.VAL (u.HookFunc, SameHeight));
END Init;
BEGIN
Init
END EASupport.